-
Notifications
You must be signed in to change notification settings - Fork 2.6k
add equality and hashability to Retry
and backoff classes
#3628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add equality and hashability to Retry
and backoff classes
#3628
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds equality and hashability methods to the Retry and various backoff classes to support reliable comparisons between retry instances in downstream libraries.
- Introduces eq and hash for Retry and multiple backoff classes.
- Augments the test suite with new test cases to validate equality/hashability behavior.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
tests/test_retry.py | Adds tests validating equality and hashability of Retry instances. |
redis/retry.py | Implements eq and hash methods for the Retry class. |
redis/backoff.py | Adds equality and hashability implementations for several backoff types. |
464721d
to
5b9fe2e
Compare
redis/backoff.py
Outdated
return ( | ||
self._base == other._base | ||
and self._cap == other._cap | ||
and self._previous_backoff == other._previous_backoff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you should not compare the _previous_backoff fields- they represent the progress/state of the objects, not the configuration. For example, it is also not included in the hash of the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I wasn't sure if the current state should affect it, but guess that's not usually what someone might care about
31e489d
to
bd59a8c
Compare
Description of change
This change adds equality and hashability to
Retry
and backoff classes.This broke in DjangoRQ (fixed) after #3622 / #3614 and I provided a workaround in rq/django-rq#706, but this allows other downstream libraries to compare two retry instances.
Pull Request check-list
Please make sure to review and check all of these items:
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.